package response

import (
	"cloud-entropy-storage-system/common/pkg/format"
	"cloud-entropy-storage-system/server/model/metadata"
	"path"
)

type MetaRender struct {
	ID        int    `json:"id"`
	FilePath  string `json:"file_path"`
	SavePath  string `json:"save_path"`
	Md        string `json:"md"`
	FileName  string `json:"file_name"`
	Flag      int    `json:"flag"`
	Size      string `json:"size"`
	IsImg     int    `json:"is_img"`
	CreatedAt string `json:"created_at"`
}

func NewMetaRender(detail metadata.MetaDetail, host string) MetaRender {
	return MetaRender{
		ID:        detail.ID,
		FilePath:  host + path.Join("/api/file", detail.FilePath),
		SavePath:  detail.FilePath,
		Md:        detail.Md,
		FileName:  detail.FileName,
		Flag:      detail.Flag,
		Size:      format.Size(detail.Size),
		IsImg:     detail.IsImg,
		CreatedAt: detail.CreatedAt.Format("2006-01-02 15:04:05"),
	}
}

type FileImgRender struct {
	ImgUrl      []string
	Count       int
	CurrentPage int
}

func NewFileImgRender(imgUrl []string, count int, currentPage int) *FileImgRender {
	return &FileImgRender{ImgUrl: imgUrl, Count: count, CurrentPage: currentPage}
}
